package com.leetcode;

import com.leetcode.Common.ListNode;

public class DeleteDuplicates_83 {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }
        ListNode slow, fast;
        slow = head;
        fast = head.next;
        while (fast != null) {
            if(fast.val != slow.val) {
                slow = slow.next;
                slow.val = fast.val;
            }
            fast = fast.next;
        }
        slow.next = null;
        return head;
    }
}
